#!/usr/bin/env python
"""
Minimal Example
===============
Generating a mask wordcloud from the article of Mr ma .
"""

from os import path
from wordcloud import WordCloud
import numpy as np
from PIL import Image
from os import path
import matplotlib.pyplot as plt
import random

d = path.dirname(__file__)

# def grey_color_func(word, font_size, position, orientation, random_state=None, **kwargs):
#     return "hsl(0, 0%%, %d%%)" % random.randint(60, 100)

mask = np.array(Image.open(path.join(d, "stormtrooper_mask.png")))

# Read the whole text.
text = open(path.join(d, '19meeting.txt')).read()

# Generate a word cloud image
wordcloud = WordCloud().generate(text)

# Display the generated image:
# the matplotlib way:


# lower max_font_size
wc = WordCloud(max_words=2000, mask=mask, margin=10,
               random_state=1).generate(text)

plt.figure()
plt.imshow(wc)
plt.axis("off")
plt.show()